<?php
class PushsController extends AppController{
	function  test(){
		$url = 'https://android.googleapis.com/gcm/send';
		$serverApiKey = "AIzaSyAmubg2LaSEzHQmKhYcboKKBzYX9J1rtGM";
		$reg = "APA91bHWfohJSW3tIKT02dBmdSihP6Fx1UwlwRh18ZCG66wMLtwmdWAscTSzaqCu7jFtGCipzPCkEZrYLLDnp3lqQYIyZqrqueDU43wraD2Kg1IwlBLBykg4hm2iUXuxm00tuUb5PIn7";

		$headers = array(
				'Content-Type:application/json',
				'Authorization:key=' . $serverApiKey
		);

		$data = array(
				'registration_ids' => array($reg)
				, 'data' => array(
						'type' => 'New',
						'title' => 'FakeTwitter',
						'msg' => 'This is message from fake twitter',
						'url' => 'http://faketwitter.com'
				)
		);

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		if ($headers)
			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

		$response = curl_exec($ch);

		curl_close($ch);
		print ($response);
	}
}